{% extends 'base.html' %}

{% block body %}

<h2>Targetindex-{{ request.args.get('target_name', '') }}</h2>

{% if session.logged_in %}
<script type="text/javascript">
    //delete entry confirm
    function delete_confirm(id) {
        var ret=confirm('please confirm that delete this entry');
        if (ret==true) {
            //alert("/delete?id="+id);
            //window.open("/delete?id="+id);
            window.location.href="/delete?id="+id;
        } else {
        }
    }
</script>

    <a href="/">&lt&ltback</a>

    <ul class=entries>
    {% for entry in entries %}
        <li><h3>{{ entry.title }}</h3>

        <p>
        <a class=createtime>{{ entry.createtime }}</a>

        {% for target in targetlists[entry.id] %}
                <a class=target href="/targetindex?target_name={{ target }}">&lt;{{ target }}&gt;</a>
        {% endfor %}
        </p>

        <p class=text>{{ entry.text|safe }}</p>

        <a href="/edit?id={{ entry.id }}">edit</a>
        <a href="javascript:void(0)" onclick="delete_confirm({{ entry.id }})">delete</a>
        </li>
    {% else %}
        <li><em>Unbelievable. No entries here so far</em>
        </li>
    {% endfor %}
    </ul>

{% else %}
    <p class=error>
    <strong>Error:</strong>
    log in please!!
    </p>

{% endif %}

{% endblock %}
